body {
    margin: 0;
    padding: 0;
    height: 100vh;
    background-color: #262626;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: sans-serif;
}

nav ul {
    display: flex;
    width: 50%;
}

nav ul li {
    position: relative;
    list-style: none;
    border: 2px solid black;
    margin-left: -2px;
    padding: 1em;
    vertical-align: middle;
}

nav ul li a {
    display: inline-block;
    z-index: 1;
    color: #fff;
    text-decoration: none;
    font-size: 1.2em;
}

nav ul li a::before {
    position: absolute;
    z-index: -1;
    top: 0;
    left: 0;
    content: '';
    display: inline-block;
    width: 100%;
    height: 100%;
    transform-origin: right;
    transform: scaleX(0);
    transition: transform 0.5s ease-in-out;
    overflow: hidden;
}

nav ul li:nth-child(1) a::before {
    background-color: #375a9d;
}

nav ul li:nth-child(2) a::before {
    background-color: #4da8f0;
}

nav ul li:nth-child(3) a::before {
    background-color: #ea5936;
}

nav ul li:nth-child(4) a::before {
    background-color: #006fb8;
}

nav ul li:nth-child(5) a::before {
    background-color: #f3535c;
}


nav ul li a:hover::before {
    transform-origin: left;
    transform: scale(1);
    transition: transform 0.5s ease-in-out;
}